import { Component, OnInit, Input } from '@angular/core'
import { Widget } from '../../model'
import { JsonApiService } from '../../../../core/api/json-api.service'

@Component({
  selector: 'time',
  templateUrl: './time.html',
  styleUrls: ['./time.css']
})
export class TimeComponent implements OnInit, Widget {
  @Input() componentData: any
  time: string = ''
  day: string = ''

  constructor(private jsonApiService: JsonApiService) {}
  ngOnInit() {
    this.showTime()
  }

  ngAfterViewInit() {
    setInterval(() => {
      this.showTime()
    }, 1000)
  }

  showTime() {
    this.time = common.getTimeHms(new Date())
    this.day = common.getTimeDay(new Date())
  }
}
